<template>
  <div class="sidepanel-container">
    <!-- Navigation -->
    <nav class="nav">
      <router-link
        to="/"
        class="nav-link"
        :class="{ active: $route.name === 'Dashboard' }"
      >
        <span v-html="dashboardIcon" class="nav-icon" />
        仪表板
      </router-link>
    </nav>

    <!-- Main Content -->
    <main class="main-content">
      <router-view />
    </main>

    <!-- Toolbar -->
    <Toolbar />
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { INLINE_ICONS } from '../assets/icons'
import Toolbar from './components/layout/Toolbar.vue'

// 图标计算属性
const dashboardIcon = computed(() => INLINE_ICONS.dashboard)
</script>

<style scoped>
.sidepanel-container {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.nav {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-right: 80px; /* 为工具栏留出空间 */
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--secondary-color);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background-color: var(--surface-color);
  color: var(--text-color);
}

.nav-link.active {
  background-color: var(--primary-color);
  color: white;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  margin-right: 80px; /* 为工具栏留出空间 */
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav,
  .main-content {
    margin-right: 60px; /* 小屏幕上工具栏较窄 */
  }
}
</style>